//Input

#include<p18F4580.h>

#pragma config WDT = OFF
#pragma config PBADEN = OFF

void main()
{
  // Initializing ports
  PORTA = 0;
  PORTB = 0xFF;

  //Set RB0-RB3 as input 
  TRISB |= 0x0F;

  //Set RA0-RA3 as output
  TRISA &= 0xF0;
	
  // If button is pressed, toggle PORTA
  while(1) 
  {
    if(PORTBbits.RB0 == 0)
    PORTA = 0x01;
    else if(PORTBbits.RB1 == 0)
    PORTA = 0x02;
    else if(PORTBbits.RB2 == 0)
    PORTA = 0x04;
    else if(PORTBbits.RB3 == 0)
    PORTA = 0x08;
	else
    PORTA = 0;
    }
}